package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.NewColleagueEntity;
import com.runen.infinitemovement.tool.CommonUtil;
import com.runen.rxnetlibrary.utils.TimeUtil;

import java.util.List;

public class NewColleagueAdapter extends BaseQuickAdapter<NewColleagueEntity.DataBean, BaseViewHolder> {
    private Context context;

    public NewColleagueAdapter(Context context) {
        super(R.layout.item_new_colleague);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, NewColleagueEntity.DataBean item) {
        String str = "%s发起的申请";
        helper.setText(R.id.tv_user_name, String.format(str, item.nickName));
        helper.setText(R.id.tv_apply_name, item.nickName);
        helper.setText(R.id.tv_branch_name, item.department);
        LinearLayout ll_btn = helper.getView(R.id.ll_btn);
        TextView tv_audit = helper.getView(R.id.tv_audit);
        helper.setText(R.id.tv_apply_phone, item.mobile);
        if (!TextUtils.isEmpty(item.createTime)) {
            helper.setText(R.id.tv_date, TimeUtil.dealDateFormat(item.createTime));
        }
        switch (item.state) {
            case 1:
                tv_audit.setText("待审核");
                ll_btn.setVisibility(View.VISIBLE);
                tv_audit.setTextColor(CommonUtil.getColor(R.color.color_FFFFA810));
                break;
            case 2:
                tv_audit.setText("审核通过");
                ll_btn.setVisibility(View.GONE);
                tv_audit.setTextColor(CommonUtil.getColor(R.color.color_FF28B566));
                break;
            case 3:
                tv_audit.setText("审核拒绝");
                ll_btn.setVisibility(View.GONE);
                tv_audit.setTextColor(CommonUtil.getColor(R.color.color_FFF63E5A));
                break;
        }
    }
}
